load ListOptionals

! number in this record
#boxnum+=1

cell GroupBox,local("Map")
  set width -1
  NewLine -3
  
  cell static,local("Title")&":"
  sizetofit
  set offset 2
  
  ! edit field with value
  #edge=#rightMargin$-#rightSkip-22-#cellSkip
  cell editvalue
  set width #edge-#hpos$
  help local("Enter title for this bounding box")

  gosub ListOptionals _PNOTE,"","","",""
  Show _OPTIONAL_TAGS
  
  ! bounding box and optional
  show _BNDS
  ShowAll _PNOTE
  
  ! Style
  Show _STYLE
  
  ! reset
  hskip 5
  cell LinkButton,local("Reset")
  set recordlink "reload" fontsize 10 controlsize small border rounded
  sizetofit
  shift #rightMargin$-#cellWidth$-#hpos$-#rightSkip
  help local("Click to reset map to origin position")
  
  ! Map
  NewLine
  #rectWidth=#rightMargin$-#leftSkip-#rightSkip
  #rectHeight=#rectWidth/1.62
  cell ExpressionField @this._BOX.i.#boxnum
  set border line Width #rectWidth Height #rectHeight
  set Width #rectWidth Height #rectHeight

  if tagexists
    NewLine 3
    cell static,local("Points of Interest")&":"
    set width -1
    
    ! Points of Interest
    ClearTabs
    ReadAll "#pois" from @_POI
    if #pois[0]=0
      #pois[0]=1
    endif
    Repeat "#i",1,#pois[0]
      newline
      if printing is false
        cell LinkButton
        set image plus border none width 20 height 20 
        Help local("Click to add another point of interest on this map")
        ! message is _BOX number in record and _POI number in the box
        set ScriptLink "Add_POI.gcscpt" ScriptType format ScriptMessage #boxnum&" "&#i
        if _POI is here
          cell LinkButton
          set image minus border none width 20 height 20
          Help local("Click to remove this point of interest")
          set ScriptLink "Remove_POI.gcscpt" ScriptType format ScriptMessage #boxnum&" "&#i
        endif
      endif
      #numpoi=#i
      Show _POI
    EndRepeat
    
  endif

endGroup
